let app = getApp();
Page({
  data: {
    navData: [{
      name: "首页",
      current: 0,
      style: 0,
      ico: 'icon-deng',
      fn: 'navJumpPage',
      id: '/pages/home/home'
    }, {
      name: "分类",
      current: 0,
      style: 0,
      ico: 'icon-fenlei',
      fn: 'navJumpPage',
      id: '/pages/classify/classify'
    }, {
      name: "购物车",
      current: 0,
      style: 0,
      ico: 'icon-gouwuche01',
      fn: 'navJumpPage',
      id: '/pages/cart/cart'
    }, {
      name: "我的",
      current: 1,
      style: 0,
      ico: 'icon-dkw_wode',
      fn: 'navJumpPage',
      id: ''
    }],
    mobelPhone: ''
  },
  onLoad() {
    let that = this;
    this.loadInfo();
    wx.getStorage({
      key: 'yewuyuanPhone',
      success(res) {
        that.setData({
          mobelPhone: res.data
        })
      },
    });
  wx.getStorage({
    key: 'openid',
    success(res) {
      that.setData({
        openid: res.data
      })
    },
  })
  },
  onGotUserInfo(e) {
    let userinfo = e.detail.userInfo;
    console.log({
      action: 'loginUserInfo1',
      openid: this.data.openid,
      WeiXinTouXiang: userinfo.avatarUrl,
      ChengShi: userinfo.country + userinfo.city,
      NiCheng: userinfo.nickName
    })
    app.get('login', {
      action: 'loginUserInfo1',
      openid: this.data.openid,
      WeiXinTouXiang: userinfo.avatarUrl,
      ChengShi: userinfo.country + userinfo.city,
      NiCheng: userinfo.nickName
    }).then((res) => {
      console.log(res)
    })
  },
  loadInfo() {
    wx.getUserInfo({
      success(e) {
        console.log(e);
      }
    })
  },
  navJumpPage(event) {
    let url = event.currentTarget.id;
    if (url) {
      wx.redirectTo({
        url: url,
      });
    }
  },

  orderPage(e) {
    wx.navigateTo({
      url: '/pages/myOrder/myOrder?current=' + e.currentTarget.id,
    })
  },
  jumpPage() {
    wx.navigateTo({
      url: '/pages/myOrder/myOrder',
    })
  },
  collectTap() {
    wx.navigateTo({
      url: '/pages/collect/collect',
    })
  },
  actionSheetTap() {
    let that = this;
    wx.showActionSheet({
      itemList: ['拨打号码', '添加客服好友'],
      success(e) {
        let index = e.tapIndex;
        if (index == 0) {
          wx.makePhoneCall({
            phoneNumber: that.data.mobelPhone,
          })
        } else if (index == 1) {
          wx.setClipboardData({
            data: that.data.mobelPhone,
            success() {
              app.toast('业务员手机号:' + that.data.mobelPhone + '复制成功');
            }
          })
        }
      }
    })
  },
})